package org.yenn.pattern.observer.weather;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 * @Author: yerenyun
 * @Description:
 */
public class ObserverPatternDemo {

    @Test
    public void update() {
        //1创建目标
        ConcreteWeatherSubject weatherSubject = new ConcreteWeatherSubject();
        //2创建观察者
        ConcreteObserver observerGirl = new ConcreteObserver();
        observerGirl.setObserverName("黄明的女朋友");
        observerGirl.setRemindThing("是我们的第一次约会，地点街心公园,不见不散哦\n");

        ConcreteObserver observerMum = new ConcreteObserver();
        observerMum.setObserverName("老妈");
        observerMum.setRemindThing("是一个购物的好日子,明天去天虹扫货\n");

        //3注册观察者
        weatherSubject.attach(observerGirl);
        weatherSubject.attach(observerMum);

        //4目标发布天气!
        weatherSubject.setWeatherContent("明天天气晴朗,蓝天白云,气温28度\n");

    }
}